﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using JLL.China.Infrastructure.Services;
using JLL.China.Model;
using JLL.China.Model.DTO;
using JLL.China.Web.Libraries;
namespace JLL.China.Web.Areas.Listings.Models
{
    public class ListingDetailModel
    {
        public Model.ListingDetail projectdir { get; set; }
        public Model.ListingDetail localprojectdir { get; set; }
    }
    // Project directory step2  

    public class ListingModel
    {
        public ListingSearchCriteria _listingCriteria;
        public int ListingID { get; set; }
        public int CountItems {get;set;}
        public int CountryID = HelperUtility.GetIdCountry();
        public ListingModel()
        {
            _listingCriteria = new ListingSearchCriteria();
        }
        private IList<Model.Listings> ListingByStatus(ListingSearchCriteria _listingCriteria)
        {
            var listing = ListingService.Search(_listingCriteria);
            CountItems = listing.Count();
            return listing;
        }
        public IList<Model.Listings> GetPostByStatus(int? status)
        {
            _listingCriteria.ListingType = "Resale";
            _listingCriteria.CountryID = CountryID;//China
            _listingCriteria.Status = status;
        //    _listingCriteria.ListingCat = "Public";
            return ListingByStatus(_listingCriteria);
        }
        public IList<Model.Listings> GetPropertyByStatus(int? status)
        {
            _listingCriteria.ListingType = "Resale";
            _listingCriteria.CountryID = CountryID;//China
            _listingCriteria.Status = status;
         //   _listingCriteria.ListingCat = "Admin";
            return ListingByStatus(_listingCriteria);
        }
        
        public IList<Model.Listings> GetPropertyInternationalByStatus(int? status)
        {
            _listingCriteria.ListingType = "Resale";
            _listingCriteria.CountryID = null;//
            _listingCriteria.Status = status;
           // _listingCriteria.ListingCat = "Admin";
            return ListingByStatus(_listingCriteria);
        }

        public IList<Model.Listings> GetProjectByStatus(int? status)
        {
            _listingCriteria.ListingType = "Project";
            _listingCriteria.CountryID = CountryID;//
            _listingCriteria.Status = status;
           // _listingCriteria.ListingCat = "Admin";

            return ListingByStatus(_listingCriteria);
        }

        public IList<Model.Listings> GetProjectInternaltionalByStatus(int? status)
        {
            _listingCriteria.ListingType = "Project";
            _listingCriteria.CountryID = null;//
            _listingCriteria.Status = status;
           // _listingCriteria.ListingCat = "Admin";
            return ListingByStatus(_listingCriteria);
        }

        public Model.Listings Listing()
        {
            var id = this.ListingID;
            if (id != null)
            {
                return ListingService.FindById(id);
            }

            return null;
            
        }
        public IList<Model.ListingMedia> ListingImages()
        {
            var id = this.ListingID;
            if(id != null)
            {
                return ListingMediaService.GetListImage(id);
            }

            return null;
            
        }
     
        public IList<Model.ProjectDirectoryMedia> ProjectDirectoryImage()
        {
            var id = this.ListingID;
            if (id != null)
            {
                return ProjectDirectoryMediaService.GetListImage(id);
            }

            return null;

        }
    }
}
